<template>
	<view class="container">
		<view class="healthindex">
			<view class="function_1">
				<text class="special">心率(次)</text>
				<input type="number" value="" v-model="heartrate" placeholder="请输入心率"
					onkeyup="this.value= this.value.match(/\d+(\.\d{0,2})?/) ? this.value.match(/\d+(\.\d{0,2})?/)[0] : ''" />
			</view>
			<view class="function_1">
				<text class="special">血压(mmHg)</text>
				<view class="gaodiya">
					<input style="width: 60%;" type="number" value="" v-model="bloodpressure_1" placeholder="请输入高压"
						onkeyup="this.value= this.value.match(/\d+(\.\d{0,2})?/) ? this.value.match(/\d+(\.\d{0,2})?/)[0] : ''" />/
					<input style="width: 35%;" type="number" value="" v-model="bloodpressure_2" placeholder="低压"
						onkeyup="this.value= this.value.match(/\d+(\.\d{0,2})?/) ? this.value.match(/\d+(\.\d{0,2})?/)[0] : ''" />
				</view>

			</view>
			<view class="function_1">
				<text class="special">血糖(mmol)</text>
				<input type="number" value="" v-model="bloodsugar" placeholder="请输入血糖"
					onkeyup="this.value= this.value.match(/\d+(\.\d{0,2})?/) ? this.value.match(/\d+(\.\d{0,2})?/)[0] : ''" />
			</view>
			<view class="function_1">
				<text class="special">血氧(%)</text>
				<input type="number" value="" v-model="bloodoxygen" placeholder="请输入血氧"
					onkeyup="this.value= this.value.match(/\d+(\.\d{0,2})?/) ? this.value.match(/\d+(\.\d{0,2})?/)[0] : ''" />
			</view>
			<view class="function_1">
				<text class="special">血脂(mmol)</text>
				<input type="number" value="" v-model="bloodfat" placeholder="请输入心血脂"
					onkeyup="this.value= this.value.match(/\d+(\.\d{0,2})?/) ? this.value.match(/\d+(\.\d{0,2})?/)[0] : ''" />
			</view>
			<view class="function_1">
				<text class="special">膳食(cal)</text>
				<input type="number" value="" v-model="diet" placeholder="请输入膳食"
					onkeyup="this.value= this.value.match(/\d+(\.\d{0,2})?/) ? this.value.match(/\d+(\.\d{0,2})?/)[0] : ''" />
			</view>
		</view>
		<view class="addcount">
			<button type="default" @click="sendCon()">上传数据</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				heartrate: "",
				bloodpressure_1: "",
				bloodpressure_2: "",
				bloodsugar: "",
				bloodoxygen: "",
				bloodfat: "",
				diet: ""
			}
		},
		methods: {
			sendCon() {
				console.log("添加上传")
				let that = this;

				uni.navigateTo({
					url: "./healthtexting", // 为指定事件添加一个监听器，获取被打开页面传送到当前页面的数据
					success: function(res) {
						// 通过eventChannel向被打开页面传送数据
						console.log(111, that.heartrate)
						res.eventChannel.emit('acceptDataFromOpenerPage', {
							data: {
								heartrate: that.heartrate,
								bloodpressure_1: that.bloodpressure_1,
								bloodpressure_2: that.bloodpressure_2,
								bloodsugar: that.bloodsugar,
								bloodoxygen: that.bloodoxygen,
								bloodfat: that.bloodfat,
								diet: that.diet
							},
						})
					}
				})
			}
		}
	}
</script>

<style>
	.container {
		width: 100%;
		padding: 0;
		font-size: 18px;
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.healthindex {
		font-size: 14px;
		width: 90%;
		height: 100%;
		display: flex;
		flex-direction: row;
		flex-wrap: wrap;
		justify-content: space-around;
	}

	.function_1 {
		width: 45%;
		height: 60px;
		margin-top: 5%;
		display: flex;
		flex-direction: column;
		align-items: center;
		border: 1px solid #dadada;
		//box阴影
		box-shadow: 2px 2px 5px #b3b3b3;
		border-radius: 5px;
	}

	.addcount {
		width: 100%;
		margin-top: 5%;
	}

	.addcount>button {
		color: #FFFFFF;
		width: 95%;
		background-color: #3774EC;
	}

	.special {
		font-size: 18px;
		width: 100%;
		text-align: center;
		color: #FFFFFF;
		border-radius: 5px 5px 0 0;
		width: 100%;
		background-color: #3774EC;
	}

	.function_1 input {
		width: 100%;
		height: 75%;
		text-align: center;
	}

	.gaodiya {
		height: 75%;
		text-align: center;
		width: 100%;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
	}

	.gaodiya>input {
		height: 75%;
		text-align: center;
		width: 100%;
	}
</style>
